package com.zhi.blog.aspect;

import com.zhi.common.validate.common.CommonThriftAspect;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionTemplate;

/**
 * 动态校验切面
 * @author ftz-lover
 * @version 1.0
 * @date 2023/9/10 12:03
 */
@Aspect
@Component
@Order(2)
public class DynamicValidate extends CommonThriftAspect {
    private TransactionTemplate transactionTemplate;

    @Around("execution(* com.zhi.blog.service..*.*(..))")
    public  Object doThriftPointCut(ProceedingJoinPoint joinPoint){
        return super.doThriftPointCut(joinPoint);
    }
    @Override
    protected boolean useBizValidator(){
        return true;
    }
    @Override
    public void onApplicationEvent(ApplicationContextEvent event){
        super.onApplicationEvent(event);
        transactionTemplate = event.getApplicationContext().getBean("transactionTemplate",TransactionTemplate.class);
    }

}
